package com.elder.web.controller.business;


import com.alibaba.fastjson2.JSONObject;
import com.elder.business.domain.OrderInfoDTO;
import com.elder.business.service.IOrderInfoService;
import com.elder.common.annotation.Anonymous;
import com.elder.common.annotation.Log;
import com.elder.common.core.domain.AjaxResult;
import com.elder.common.core.page.TableDataInfo;
import com.elder.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderInfoController {

    @Autowired
    private IOrderInfoService orderInfoService;

    @Anonymous
    @Log(title = "订单创建", businessType = BusinessType.INSERT)
    @RequestMapping("/order/info/create")
    public AjaxResult createOrderInfo(@RequestBody OrderInfoDTO orderInfo) {
        return AjaxResult.success(orderInfoService.createOrderInfo(orderInfo));
    }
    @Anonymous
    @Log(title = "订单信息添加", businessType = BusinessType.INSERT)
    @RequestMapping("/order/info/add")
    public AjaxResult addOrderInfo(@RequestBody OrderInfoDTO orderInfo) {
        return AjaxResult.success(orderInfoService.addOrderInfo(orderInfo));
    }
    @Anonymous
    @RequestMapping("/order/info/list")
    public TableDataInfo getOrderInfoList(String elderName, String orderTime, Integer pageNum, Integer pageSize ) {
        return orderInfoService.getOrderInfoList(elderName, orderTime, pageNum, pageSize);
    }
    @Anonymous
    @RequestMapping("/order/info/get")
    public JSONObject getOrderInfoById(Long orderId) {
        return orderInfoService.getOrderInfoById(orderId);
    }

    @Anonymous
    @Log(title = "订单状态更新", businessType = BusinessType.UPDATE)
    @RequestMapping("/order/info/update")
    public AjaxResult updateOrderInfo(String orderId) {
        return orderInfoService.updateOrderStatus(orderId);
    }
}
